package com.yjhb.android.sbz.mvp.reward;

import com.yjhb.android.sbz.entity.reward.Reward;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2021/1/15 15:46
 */
public class RewardPresenter extends ConventionPresenter<RewardView> {
    private final String TAG = "RewardPresenter";

    @Override
    protected void onDestroy() {

    }

    public RewardPresenter(RewardView rewardView) {
        super(rewardView);
    }


    /**
     * 阶段奖励规则列表
     *
     * @param rankType
     */
    public void getStageInfo(Integer rankType) {
        HttpTool.request(model.getStageInfo(rankType), new HttpObserver<List<Reward>>() {
            @Override
            public void onResult(List<Reward> data) {
                if (view != null) {
                    view.onRewardRuleList(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }


    /**
     * 用户奖励信息
     *
     * @param type
     */
    public void rankAgentInfo(Integer type) {
        HttpTool.request(model.rankAgentInfo(type), new HttpObserver<Object>() {
            @Override
            public void onResult(Object data) {
                if (view != null) {
                    view.onUserRewardInfo(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });

    }


    /**
     * 领奖励
     *
     * @param type
     */
    public void getRankReward(Integer type) {
        if (view != null) {
            view.onWait();
        }
        HttpTool.request(model.getRankReward(type), new HttpObserver<Object>() {

            @Override
            public void onResult(Object data) {
                if (view != null) {
                    view.onGetSuccess();
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }


}
